#ifndef _GOVT_QUEST_HPP_
#define _GOVT_QUEST_HPP_

/*******************************************************************************
 ** Name: quest.hpp                                                           **
 ** Description:                                                              **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved CDDL License                        **
 **                                                                           **
 **  Copyright (c) 2009-2010 Barry Gian James  <bjames@gamingods.net>         **
 **  All rights reserved.                                                     **
 **                                                                           **
 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       **
 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED **
 ** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           **
 ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT        **
 ** HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    **
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  **
 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR    **
 ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    **
 ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      **
 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        **
 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              **
 **                                                                           **
 ******************************************************************************/
// Portions (c) 2011-2012 Open Design Strategies, LLC.
// Created on April 4, 2010, 10:03 AM
// Modified $Date: 2012-08-14 20:47:30 -0600 (Tue, 14 Aug 2012) $ by $Author: unknown $
#define quest_hpp_ID   "$Id: quest.hpp 69068 2012-08-15 02:47:30Z unknown $"
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>

#include <string>
#include "common.hpp"


// Types of motivation for NPCs (mostly wrt assignments and missions)
enum class NPCQuestMotivation : uint8_t {
	Knowledge, Comfort, Reputation, Serenity, Protection,
	Conquest, Wealth, Ability, Items
};

enum class AtomicQuestActions : int {
	Unknown = 0,
	Done = 1, Capture = 2, Damage = 3, Defend = 4, Escort = 5,
	Exchange = 6, Experiment = 7, Explore = 8, Gather = 9,
	Give = 10, Goto = 11, Kill = 12, Listen = 13, Read = 14,
	Repair = 15, Report = 16, Spy = 17, Stealth = 18, Take = 19,
	Use = 20
};

enum class QuestObjectiveType
{
	Item, Mob, Boss, Intangible
};

#pragma db value
struct QuestObjective
{
	QuestObjectiveType	type;
	uint8_t				num;	// number of items or kills
	entity_t			objective;
};

#pragma db object table("quests")
class Quest
{
public:
	SMART_PTR_DECL(Quest);

	Quest();
	virtual ~Quest() { }

	void		GenObjectives();

	// Getters
	const entity_t	ID() const { return _id; }
	const uint8_t	ThreatLevel() const { return _qtl; }
	const std::string & Name() const { return _name; }
	const std::string & Desc() const { return _desc; }
	const entity_t Next() const { return _next; }
	const char *	Motivation() const { return _npcmotivations[(uint8_t)_motivation]; }
	const int		XP() const { return _xp; }
	const QuestObjective & Objective() const { return _objective; }
	const entity_t	Giver() const { return _giver; }

	// Setters
	void	ThreatLevel(const uint8_t t) { _qtl = t; }
	void	Desc(const std::string & s) { _desc = s; }
	void	Next(const entity_t e) { _next = e; }
	void	Name(const std::string & n) { _name = n; }
	void	XP(const int x) { _xp = x; }
	void	Objective(QuestObjectiveType t, uint8_t n, entity_t o) {
		_objective.type = t;
		_objective.num = n;
		_objective.objective = o;
	}
	void	Giver(const entity_t t) { _giver = t; }

private:
	friend class odb::access;

	#pragma db id auto
	entity_t		_id;
	uint8_t			_qtl;	// quest threat level
	std::string		_name;
	entity_t		_next;
	std::string		_desc;
	int				_xp;
	entity_t		_giver;

	NPCQuestMotivation	_motivation;
	QuestObjective	_objective;

	static const char * _npcmotivations[];
};

// For storage of player quests completed and in progress
#pragma db object table("quests_player")
struct PlayerQuest
{
	entity_t	player_;
	entity_t	quest_;
	int			num_;	// how many out of the num required completed
	bool		completed_;
	std::map<std::string,std::string> _properties;

	void		AddProperty(const std::string & k, const std::string v) { _properties[k] = v; }
};

/**************** @Deprecated **********************/
//enum class QuestObjectiveType : uint8_t {
//	SkillCheck, Aid, Acquire, Capture, Confirm, Defend, Destroy,
//	Evade, Infiltrate, Investigate, Neutralize, Repair, Craft,
//	Rescue, Transport,
//	max
//};
//
//struct QuestObjective
//{
//	uint8_t		grade;		// 1 - 10
//	QuestObjectiveType	type;
//	boost::uuids::uuid 		objectiveID;
//};
////! Represents different stages in missions that have them.
////! All missions have at least two stages:
////! Stage 0 - getting the mission and Stage # - mission complete
//struct QuestStage
//{
//	uint8_t			percent;	// this stage represents what percentage complete?
//	std::string		desc;
//	bool			bComplete;	// the last stage of a mission progression
//};
//
//#define MISSION_STAGE_OFFSET	2	// offset into stages[] to get mission
////! The quintessential mission/quest/task/job.
////! The list of
//class Quest
//{
//public:
//	Quest() { }
//	Quest(std::string n,int x,NPC * wo);
//	virtual ~Quest();
//
//	SMART_PTR_DECL(Quest)
//
//	// Getters
//	const std::string &		Name() const { return _name; }
//	const int				XP() const { return _xp; }
//	const NPC::pointer	QuestGiver() const { return _quest_giver; }
//	const std::string &		Desc() const { return _desc; }
//	QuestStage *	GetStage(int s) { if (s <= _num_stages) return _stages[s]; else return NULL; }
//	const int		NumStages() const { return _num_stages; }
//
//	// Setters
//	void		NumStages(int s) { _num_stages = s; }
//	void		Desc(std::string d) { _desc = d; }
//	void		Name(const std::string & n) { _name = n; }
//	void		XP(const int x) { _xp = x; }
//	void		QuestGiver(const NPC::pointer & n) { _quest_giver = n; }
//
//private:
//	std::string		_name;
//	std::string		_desc;
//	int		_xp;		// how much is this mission worth
//	NPC::pointer 	_quest_giver;
//	QuestStage **	_stages;
//	int				_num_stages;
//	QuestObjective	_objective;
//};




#endif /* _GOVT_QUEST_HPP_ */
